package com.bruan.create_thread;

import java.util.concurrent.Callable;

//1继承callable接口
public class MyCallable implements Callable<String> {
    private int n;
    public MyCallable(int n){
        this.n = n;
    }
    @Override
    //2描述线程任务，返回执行结果
    public String call() throws Exception {
        int sum = 0;
        for (int i = 0; i <= n; i++) {
            sum += i;

        }
        return "线程求出1-"+n+"的值是:"+sum;
    }
}
